home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PsL Monthly 1993 December
/
PSL Monthly Shareware CD-ROM (December 1993).iso
/
prgmming
/
win
/
c
/
3d_dll.exe
/
DEMODLG.C
< prev
next >
Wrap
C/C++ Source or Header
|
1991-10-21
|
9KB
|
284 lines
#include <windows.h>
#include <string.h>
#include "ids.h"
#include "demo.h"
#include "three_d.h"
BOOL FAR PASCAL DemoDlgProc(HWND,WORD,WORD,LONG);
BOOL FAR PASCAL ComboDlgProc(HWND,WORD,WORD,LONG);
BOOL FAR PASCAL AboutDlgProc(HWND,WORD,WORD,LONG);
static void AdjustPosition(HWND);
extern HANDLE hInst;
/*
****************************************************************************
DemoDlgProc()
Handles all messages for the 3-D demo dialog box.
****************************************************************************
*/
BOOL FAR PASCAL DemoDlgProc(HWND hDlg, WORD msg, WORD wParam, LONG lParam)
{
FARPROC lpprocAboutDlg;
switch (msg)
{
case WM_INITDIALOG:
AdjustPosition(hDlg);
/* Fill listboxes and combo boxes with current directory listing */
DlgDirList(hDlg,"*.*",IDD_9,NULL,0x0000);
DlgDirListComboBox(hDlg,"*.*",IDD_12,NULL,0x0000);
DlgDirListComboBox(hDlg,"*.*",IDD_13,NULL,0x0000);
DlgDirListComboBox(hDlg,"*.*",IDD_14,NULL,0x0000);
/* Hide group boxes which will be made three_d */
ShowWindow(GetDlgItem(hDlg,IDD_6),SW_HIDE);
ShowWindow(GetDlgItem(hDlg,IDD_7),SW_HIDE);
break;
case WM_CTLCOLOR: /* Allow DLL to handle this one */
return(Control3dColor(hDlg,wParam));
case WM_PAINT:
/* This posts a message to the DLL defined message WM_3DPAINT */
/* It is very important to return FALSE here, to allow the dialog */
/* handler to process the WM_PAINT message first */
PostMessage(hDlg,WM_3DPAINT,0,0L);
return (FALSE);
case WM_3DPAINT:
/* This code calls functions in the DLL to make the controls in the */
/* dialog box 3-D */
Draw3dFrame(hDlg,INSIDE_FRAME);
Draw3dBorder(hDlg,IDD_1,RECESSED,1);
Draw3dBorder(hDlg,IDD_2,RAISED,1);
Draw3dBorder(hDlg,IDD_3,RECESSED,2);
Draw3dBorder(hDlg,IDD_4,RAISED,2);
Draw3dShadow(hDlg,IDD_5);
Draw3dBorder(hDlg,IDD_6,RECESSED,3);
Draw3dBorder(hDlg,IDD_7,CREASED,3);
Draw3dShadow(hDlg,IDD_8);
Draw3dBorder(hDlg,IDD_9,RECESSED,1);
Draw3dBorder(hDlg,IDD_10,RAISED,1);
Draw3dShadow(hDlg,IDD_11);
Draw3dBorder(hDlg,IDD_12,RECESSED,2);
Draw3dBorder(hDlg,IDD_13,RAISED,2);
Draw3dShadow(hDlg,IDD_14);
Draw3dBorder(hDlg,IDD_15,RECESSED,3);
Draw3dBorder(hDlg,IDD_16,RAISED,3);
Draw3dShadow(hDlg,IDD_17);
Draw3dBorder(hDlg,IDOK,RECESSED,2);
Draw3dBorder(hDlg,IDCANCEL,RECESSED,2);
Draw3dBorder(hDlg,IDD_ABOUT,RECESSED,2);
break;
case WM_COMMAND:
switch(wParam)
{
case IDOK:
case IDCANCEL:
EndDialog(hDlg,TRUE);
break;
case IDD_ABOUT:
lpprocAboutDlg = MakeProcInstance(AboutDlgProc,hInst);
DialogBox(hInst,"AboutBox",hDlg,lpprocAboutDlg);
FreeProcInstance(lpprocAboutDlg);
break;
default:
return (FALSE);
}
break;
default:
return(FALSE);
}
return (TRUE);
}
/*
****************************************************************************
ComboDlgProc()
Handles all messages for the 3-D combo dialog box.
****************************************************************************
*/
BOOL FAR PASCAL ComboDlgProc(HWND hDlg, WORD msg, WORD wParam, LONG lParam)
{
LPMEASUREITEMSTRUCT lpmis;
LPDRAWITEMSTRUCT lpdis;
HDC hdc;
static HFONT hFont;
HFONT hOldFont;
int nMode;
DWORD dwOldClr;
switch (msg)
{
case WM_INITDIALOG:
AdjustPosition(hDlg);
hFont = CreateFont(16,5,0,0,700,0,0,0,ANSI_CHARSET,OUT_DEFAULT_PRECIS,
CLIP_DEFAULT_PRECIS,PROOF_QUALITY,VARIABLE_PITCH|FF_SWISS,"Helv");
DlgDirList(hDlg,"*.*",IDD_LIST,NULL,0x0000);
DlgDirListComboBox(hDlg,"*.*",IDD_COMBO,NULL,0x0000);
break;
case WM_CTLCOLOR: /* Allow DLL to handle this one */
return(Control3dColor(hDlg,wParam));
case WM_PAINT:
/* This posts a message to the DLL defined message WM_3DPAINT */
/* It is very important to return FALSE here, to allow the dialog */
/* handler to process the WM_PAINT message first */
hdc = GetDC(hDlg);
hOldFont=SelectObject(hdc,hFont);
nMode = SetBkMode(hdc,TRANSPARENT);
SetTextColor(hdc,GetSysColor(COLOR_BTNSHADOW));
TextOut(hdc,6,6,(LPSTR)"3-D Ownerdraw list/combo boxes",30);
dwOldClr = SetTextColor(hdc,RGB(255,255,255));
TextOut(hdc,5,5,(LPSTR)"3-D Ownerdraw list/combo boxes",30);
SetBkMode(hdc,nMode);
SetTextColor(hdc,dwOldClr);
SelectObject(hdc,hOldFont);
ReleaseDC(hDlg,hdc);
PostMessage(hDlg,WM_3DPAINT,0,0L);
return (FALSE);
case WM_3DPAINT:
/* This code calls functions in the DLL to make the controls in the */
/* dialog box 3-D */
Draw3dFrame(hDlg,OUTSIDE_FRAME);
Draw3dBorder(hDlg,IDD_COMBO,RECESSED,2);
Draw3dBorder(hDlg,IDD_LIST,RECESSED,2);
Draw3dBorder(hDlg,IDOK,RECESSED,2);
break;
case WM_MEASUREITEM:
/* Set the height of items in the listbox and combo box */
lpmis = (LPMEASUREITEMSTRUCT)lParam;
/* Use vertical dialog base unit + 2 */
lpmis->itemHeight = HIWORD(GetDialogBaseUnits()) + 2;
break;
case WM_DRAWITEM:
/* If there were other owner-draw controls here, you would need a */
/* switch statement to handle them. For now, just do the listbox */
/* and the combo box */
lpdis = (LPDRAWITEMSTRUCT)lParam;
if (lpdis->itemID == -1)
Handle3dFocus(lpdis); /* No items yet, just do focus */
else
{
Draw3dItem(lpdis); /* Draw entire item selected or not */
Handle3dFocus(lpdis); /* Handle focus */
}
break;
case WM_COMMAND:
switch(wParam)
{
case IDOK:
case IDCANCEL:
EndDialog(hDlg,TRUE);
break;
default:
return (FALSE);
}
break;
case WM_DESTROY:
DeleteObject(hFont);
break;
default:
return(FALSE);
}
return (TRUE);
}
BOOL FAR PASCAL AboutDlgProc(HWND hDlg, WORD msg, WORD wParam, LONG lParam)
{
switch (msg)
{
case WM_INITDIALOG:
AdjustPosition(hDlg);
break;
case WM_CTLCOLOR:
return(Control3dColor(hDlg,wParam));
case WM_PAINT:
PostMessage(hDlg,WM_3DPAINT,0,0L);
return (FALSE);
case WM_3DPAINT:
Draw3dFrame(hDlg,OUTSIDE_FRAME);
Draw3dBorder(hDlg,IDD_ICON1,RAISED,2);
Draw3dBorder(hDlg,IDD_HEADER,RECESSED,2);
Draw3dBorder(hDlg,IDD_ICON2,RAISED,2);
Draw3dShadow(hDlg,IDD_RECT);
break;
case WM_COMMAND:
switch(wParam)
{
case IDOK:
EndDialog(hDlg,TRUE);
break;
default:
return (FALSE);
}
break;
default:
return(FALSE);
}
return (TRUE);
}
/*
****************************************************************************
AdjustPosition()
Adjusts the position of the passed window so that it is centered both
horizontally and vertically in the client of the main window.
****************************************************************************
*/
void AdjustPosition(hWindow)
HWND hWindow;
{
RECT hRect;
short xSize,ySize,xPos,yPos;
sho